<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请输入数字" v-model="num">
  <button @click="guess()">按钮</button>
  <h3>{{tips}}</h3>
</template>

<script setup>
import {ref} from 'vue';

const num =ref('');
const tips =ref('');

let result = parseInt(Math.random()*100)+1;
console.log(result);

const guess = ()=>{
  if (num.value < result){
    tips.value='猜小了';
  }else if(num.value>result){
    tips.value='猜大了';
  }else{
    tips.value='猜对了';
  }
};

</script>


<style scoped>

</style>